cmake_minimum_required(VERSION 3.28)
project(nes8 VERSION 0.1.0 LANGUAGES C CXX)

# Turning off extensions avoids an issue with the clang 16 compiler
# clang 17 and greater can avoid this setting
set(CMAKE_CXX_EXTENSIONS OFF)
# Set the version of C++ for the project
set(CMAKE_CXX_STANDARD 23)

file(GLOB src_module_ixx  "src/module/*.ixx" ) #模块接口单元
file(GLOB src_module_cpp  "src/module/*.cpp" )  #模块实现单元

# message(${src_module_cpp})

add_library(nes8_module)

target_sources(nes8_module
# PRIVATE
# "src/module/6502.cpp"
  PUBLIC
    FILE_SET CXX_MODULES FILES
    ${src_module_ixx} #必须是模块接口或分区
    
    ${src_module_cpp} #必须是模块接口或分区
)

set(appname ${PROJECT_NAME})
add_executable(${appname} src/main.cpp )

find_package(doctest REQUIRED)

# Link to the library foo   
find_package(spdlog REQUIRED)

# https://github.com/libSDL2pp/libSDL2pp
find_package(SDL2pp REQUIRED)
set(SDL2PP_WITH_IMAGE ON) # if you need SDL_image support
set(SDL2PP_WITH_MIXER ON) # if you need SDL_mixer support
set(SDL2PP_WITH_TTF ON) # if you need SDL_ttf support

# 自己的模块库,目前需要c++版本一致,所以需要设置库版本
# add_subdirectory(lsf)
# set_property(TARGET lsf PROPERTY CXX_STANDARD 23)

target_link_libraries(nes8_module PRIVATE 
    SDL2pp::SDL2pp
)

set_property(TARGET nes8_module PROPERTY CXX_STANDARD 23)
target_link_libraries(${appname} nes8_module)

file(GLOB tests_src  "src/tests/*.cpp" )  #测试单元

add_executable(doc_test ${tests_src})

target_link_libraries(doc_test PRIVATE doctest::doctest)
target_link_libraries(doc_test PRIVATE nes8_module)


#模板https://www.kitware.com/import-cmake-the-experiment-is-over/
